# accounts/urls.py
from django.urls import path
from .views import *
from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [
    path('', home_view, name='home'),
    path('register/', register_view, name='register'),
    path('login/', login_view, name='login'),
    path('logout/', logout_view, name='logout'),
    path('dashboard/', dashboard_view, name='dashboard'),
    path('encrypt/', text_encrypt_view, name='text_encrypt'),
    path('history/', encryption_history_view, name='encryption_history'),
    path('detail/<uuid:pk>/', encryption_detail_view, name='encryption_detail'),
    #新增路由
    path('profile/', user_profile_view, name='user_profile'),
    path('profile/<int:user_id>/', user_profile_view, name='user_profile_by_id'),
    path('edit-profile/', user_edit_view, name='user_edit'),

    path('input-data/', input_data, name='input_data'),

    path('agricultural-products/', agricultural_product_list, name='agricultural_product_list'),
    path('agricultural-products/decrypt/<int:product_id>/', decrypt_agricultural_data, name='decrypt_agricultural_data'),
    #卖东西
    path('product/sell/', product_sell, name='product_sell'),
    path('product/<int:product_id>/sell/', sell_product, name='sell_product'),
# 产品目录
    path('catalog/', product_catalog, name='product_catalog'),
    path('order/<int:product_id>/', place_order, name='place_order'),
#  订单历史
    path('order/history/', order_history_view, name='order_history'),
# 取消订单
    path('order/cancel/<int:order_id>/', cancel_order, name='cancel_order'),

    path('product/toggle/<int:product_id>/', toggle_product_listing, name='toggle_product_listing'),

    path('product/edit/<int:product_id>/', edit_agricultural_product, name='edit_agricultural_product'),

    path('sold_orders/all/', sold_orders_all, name='sold_orders_all'),
    path('order/<int:order_id>/details/', order_details, name='order_details'),

    path('product/delete/<int:product_id>/', delete_agricultural_product, name='delete_agricultural_product'),

    path('user/edit/<int:user_id>/', user_edit, name='user_edit')

]

if settings.DEBUG:
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)